<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


//prefix前缀防冲突，url的前缀.namespace命名空间为控制器统一添加，节省代码。as别名，路由名称的前缀
Route::group(['prefix' => 'Edu/admin', 'middleware' => ['auth', 'admin'], 'namespace' => 'Admin', 'as' => 'edu.admin.'], function () {
    Route::get('/', 'AdminController@index')->name('index');
    Route::resource('tag', 'TagController');
    Route::resource('lesson', 'LessonController');
    Route::resource('system', 'SystemController');

    Route::post('system-search', 'LessonController@search')->name('lesson.search');

    Route::resource('subscribe', 'SubscribeController');
});

Route::group(['prefix' => 'Edu', 'middleware' => ['front'], 'namespace' => 'Front', 'as' => 'edu.front.'], function () {
    Route::resource('topic', 'TopicController');
    Route::resource('lesson', 'LessonController')->only(['index', 'show']);
    Route::resource('system', 'SystemController')->only(['index', 'show']);
    Route::resource('video', 'VideoController')->only(['index', 'show']);
    Route::resource('sign', 'SignController')->only(['index', 'store', 'destroy']);


    //only路由对应的控制器方法名称
    Route::resource('{model}/{id}/comment', 'CommentController')->only(['index', 'store', 'destroy']);
    Route::get('live', 'LiveController@index')->name('live.index');
    Route::get('live/{live}', 'LiveController@show')->name('live.show')->middleware('auth');
    Route::get('live/push', 'LiveController@push')->name('live.push');
    Route::any('live/notify', 'LiveController@notify')->name('live.notify');
    Route::post('chat/init', 'ChatController@init')->name('chat.init');
    Route::post('chat/send', 'ChatController@send')->name('chat.send');
    Route::get('subscribe','SubscribeController@index')->name('subscribe.index');
    Route::get('subscribe/alipay/{subscribe}','SubscribeController@alipay')->name('subscribe.alipay');
    Route::get('subscribe/wepay/{subscribe}','SubscribeController@wepay')->name('subscribe.wepay');


});

Route::group(['prefix' => 'Edu/center/{user}', 'middleware' => ['front'], 'namespace' => 'Center', 'as' => 'edu.center.'], function () {
    Route::resource('topic', 'TopicController')->only('index');
    Route::resource('follower', 'FollowerController')->only('index');
    Route::resource('fan', 'FanController')->only('index');
    Route::resource('/{model}/favorite', 'FavoriteController')->only('index');
    Route::resource('study-path', 'StudyPathController')->only('index');
});

Route::group(['prefix' => 'Edu/member', 'middleware' => ['auth', 'front'], 'namespace' => 'Member', 'as' => 'edu.member.'], function () {
    Route::resource('topic', 'TopicController')->only('index');
    Route::resource('live', 'LiveController')->only('index');
    Route::resource('message', 'MessageController')->only(['index', 'destroy', 'show']);
});
